import axios from 'axios';

const instance = axios.create({
  baseURL: 'http://localhost:8090/api',
  timeout: 3000,
});

export function get(url, params) {
  return new Promise((resolve, reject) => {
    instance
      .get(url, {
        params: params,
      })
      .then(res => {
        if (res.status === 200) {
          if (res.data.success) {
            resolve(res.data.data);
          } else {
            throw new Error(res.data.msg);
          }
        }
      }).catch(e => {
        throw new Error("访问超时")
      })
  });
}
